package BaseService

import (
	"gdshop-back-end-go/client-api/app/request/HomeReq"
	"gdshop-back-end-go/common/libs/clickCaptcha"
	"gdshop-back-end-go/common/response"
	"github.com/gogf/gf/net/ghttp"
)

func CaptchaCheck(r *ghttp.Request, parames *HomeReq.CaptchaCheck) *response.JsonResponse {
	ctx := r.GetCtx()
	check, err := clickCaptcha.CaptchaCheck(ctx, parames.CaptchaKey, parames.CaptchaDots)
	if err != nil {
		return response.FailByRequestMessage(r, "验证失败")
	}

	if !check {
		return response.FailByRequestMessage(r, "验证失败")
	}

	return response.SuccessByRequestMessage(r, "验证成功")
}
